package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-20
 * Time: 20:36
 */
abstract class Shape{
    //抽象方法
    public abstract void draw();

}

/*abstract class A extends Shape{

}
class B extends A {
    @Override
    public void draw() {
        System.out.println("hhhhhh");
    }
}*/

class Rect extends Shape{
    @Override
    public void draw() {
        System.out.println("矩形");
    }
}

class Cycle extends Shape {
    @Override
    public void draw() {
        System.out.println("画圆");
    }
}

class Triangle extends Shape {
    @Override
    public void draw() {
        System.out.println("画三角形");
    }
}

class Flower extends Shape {
    @Override
    public void draw() {
        System.out.println("画❀");
    }
}

public class Test {

    public static void drawMap(Shape shape){
        shape.draw();
    }

    public static void main(String[] args) {
        Rect rect = new Rect();
        drawMap(rect);

        drawMap(new Cycle());
        drawMap(new Triangle());

        drawMap(new Flower());
    }

    public static void main1(String[] args) {
        //Shape shape = new Shape();
        Shape shape = new Rect();
    }
}
